package it.unipd.dei.es1011.nucularc0d3.defaultproject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

public class RecordingEnded extends Activity {

	private Button gotoList;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.recording_ended); // setting layout
		
		gotoList  = (Button) findViewById(R.id.toListSessions);
		gotoList.setOnClickListener(sendToListActivity);
		
		float[] maxValue = getIntent().getFloatArrayExtra("axisMaxValue");
		float[] minValue = getIntent().getFloatArrayExtra("axisMinValue");
		
		TextView tempValues = (TextView) findViewById(R.id.xMaxValue);
		tempValues.setText(""+maxValue[0]);
		tempValues = (TextView) findViewById(R.id.yMaxValue);
		tempValues.setText(""+maxValue[1]);
		tempValues = (TextView) findViewById(R.id.zMaxValue);
		tempValues.setText(""+maxValue[2]);

		tempValues = (TextView) findViewById(R.id.xMinValue);
		tempValues.setText(""+minValue[0]);
		tempValues = (TextView) findViewById(R.id.yMinValue);
		tempValues.setText(""+minValue[1]);
		tempValues = (TextView) findViewById(R.id.zMinValue);
		tempValues.setText(""+minValue[2]);
		
		tempValues = (TextView) findViewById(R.id.sampleCollectedItemValueTextView);
		tempValues.setText(""+getIntent().getLongExtra("numberSampleCollected", 0));
		
		tempValues = (TextView) findViewById(R.id.elapsedTimeValueTextView);
		tempValues.setText(""+getIntent().getStringExtra("totalTime"));
	}

//	/**
//	 * Standard override to get key-press events.
//	 * I put it to avoid accidentally start recording.
//	 */
//	@Override
//	public boolean onKeyDown(int keyCode, KeyEvent msg) {
//		if(keyCode == KeyEvent.KEYCODE_BACK){
//			startActivity(new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));  // TODO
//			finish();
//			return true;
//		}
//		return super.onKeyDown(keyCode, msg);
//	}
	
	/**
	 * Second button's listener, it will send the user to the List of the Sessions
	 */
	OnClickListener sendToListActivity = new OnClickListener() {
		public void onClick(View v) {
			// TODO
			startActivity(new Intent(getBaseContext(), ListSessionsActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
			finish();
		}
	};
}
